<?php
class GoodsAction extends BaseAction{
	// 首页
	public function index(){
		/**用来处理带有条件的查询**/
		$partner_id = $_SESSION['qp_parent_id'];
		$sort_id = $_REQUEST['sort_id'];

		if(empty($_REQUEST['order']))$_REQUEST['order']='new';

		$map['gsort']=$sort_id;
		$map['pid']=$partner_id;
		$pdata = D('Partner','Admin')->selectPartnerInfo(array('porppid'=>$_SESSION['qp_id']));
		$map['checker'] = getSubByKey($pdata,"id");
		$pagedata = service('Statistics')->statGoods4Checked($map,$_REQUEST['order'],true,10);
		//dump($pagedata);
		//$ppagedata = service('Statistics')->statPartner4Checked($map,$_REQUEST['order'],true,4);
		//dump($ppagedata);
		$this->assignRequestParams();
		$this->assign('pagedata', $pagedata);
		$this->display();
	}
	
	public function gdetail(){
		$partner_id = $_SESSION['qp_parent_id'];
		$goods_id = $_REQUEST['gid'];
		$gdata = D('Goods','Admin')->selectGoodsInfo(array('pid'=>$partner_id,'gid'=>$goods_id),'*');
		if(empty($gdata))$this->error('商品不存在！');
		$pdata = D('Partner','Admin')->selectPartnerInfo(array('porppid'=>$map['pid'],'psort'=>$map['psort']),'id',null,null);
		$ary_pids = getSubByKey($pdata,"id");
		$couponpagedata = model('Coupon')->search4SH(array('pid'=>$ary_pids,'gid'=>$goods_id) ,'check_time desc', 4);
		$price = D('GoodsPrice','Admin')->selectRecentPriceByGoodsId($goods_id);
		
		$this->assign('couponpagedata', $couponpagedata);
		$this->assign('goods', $gdata[0]);
		$this->assign('price', $price);
		$this->display();
	}
}

?>